var ctxPath = "/education";

$.getUrlParam = function (name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
};


!function ($) {

    var initMember = function() {
        $.ajax({
            url: ctxPath + '/wx/api/customer/getCustomerInfo',
            type: 'post',
            dataType: 'json',
            success: function (result) {
                if(result.returnCode == 0) {
                    $(".member-name").html(result.customerName);
                    // $(".member-num").html(result.customerCode);
                    $("#myPoint").html(result.point);

                    //如果类型为推荐人显示，积分，积分商城，积分商城订单
                    if(result.customerType == 2){
                        $(".recommenderType").show();
                    }else{
                        $(".recommenderType").hide();
                    }

                    $("#myOrders").attr("href", "/education/wx/orders.html?tab=all-tab");
                    $("#un-pay-tab").attr("href", "/education/wx/orders.html?tab=un-pay-tab");
                    $("#applies-tab").attr("href", "/education/wx/orders.html?tab=applies-tab");
                    $("#pays-tab").attr("href", "/education/wx/orders.html?tab=pays-tab");
                    $("#complete-tab").attr("href", "/education/wx/orders.html?tab=complete-tab");
                } else {
                    alert(result.returnMsg);
                    location.href = ctxPath + "/wx/customerLogin.html";
                }
            }
        });
    };

    initMember();

    $(".member-shop").click(function () {
        window.location.href = ctxPath + "/wx/home.html";
    })

}(jQuery);